package com.gitee.wsl.mathematics.function

import kotlin.math.floor


fun snapped(value: Int, step: Int) = if (step != 0) {
    (floor(value.toDouble() / step.toDouble() + 0.5) * step).toInt()
} else {
    value
}

fun snapped(value: Double, step: Double) = if (step != 0.0) {
    floor(value / step + 0.5) * step
} else {
    value
}